﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SocialLotus.DAO;
using SocialLotus.Entities.TestArea;

namespace SocialLotus.BL.TestArea
{
    public class TestBL : BaseBL
    {
        #region Constructors
        public TestBL(DAOSession session) : base(session) { }
        #endregion

        #region Get-Methods
        public IList<Test> GetAll()
        {
            return Session.GetGenericDAO<Test>().GetList();
        }

        public Test GetById(int iD)
        {
            return Session.GetGenericDAO<Test>().GetById(iD);
        }

        public Test GetByName(string name)
        {
            return Session.GetGenericDAO<Test>().GetList(f => f.Name == name).FirstOrDefault();
        }
        #endregion

        #region Save-Methods
        public Test SaveOrUpdate(Test test)
        {
            return Session.GetGenericDAO<Test>().SaveOrUpdate(test);
        }

        public Test Save(string name)
        {
            Test test = new Test() { Name = name };

            return Session.GetGenericDAO<Test>().SaveOrUpdate(test);
        }
        #endregion

    }
}
